package com.tencent.sr.iris.basic.saas.service.util;

import com.tencent.sr.iris.activity.interfaces.enums.ActivityIdEnum;
import com.tencent.sr.iris.activity.interfaces.enums.ActivityTypeEnum;
import com.tencent.sr.iris.basic.saas.service.model.activity.*;
import lombok.extern.slf4j.Slf4j;

import java.util.Objects;

/**
 * 导师工具类
 *
 * @author nixiaolin
 * @date 2023/2/8 11:39
 */
@Slf4j
public abstract class ActivityExportUtils {


    /**
     * 活动详情导出Class对象
     *
     * @param activityType
     * @param activityId
     * @return
     */
    public static Class<? extends BaseActivityTaskExportInfo> getExportClass(String activityType, String activityId) {
        ActivityTypeEnum activityTypeEnum = ActivityTypeEnum.getByCode(activityType);
        if (activityTypeEnum == null) {
            return BaseActivityTaskExportInfo.class;
        }

        switch (activityTypeEnum) {
            case INVITE_GIFT:
                if (Objects.equals(activityId, ActivityIdEnum.INVITE_GIFT.getCode())) {
                    return InviteActivityTaskExportInfo.class;
                }
                return InviteActivityTaskBaseExportInfo.class;
            case MONTH_GIFT:
                return MonthGiftActivityTaskExportInfo.class;
            case REGIST_GIFT:
                return RegistGiftActivityTaskExportInfo.class;
            case LEVEL_UP_FOSTER_GIFT:
            case GUIDE_ALLOWANCE:
                return LevelUpActivityTaskExportInfo.class;
            case LEVEL_UP_PROMO_GIFT:
                return LevelUpPromoActivityTaskExportInfo.class;
            default:
                return BaseActivityTaskExportInfo.class;
        }
    }

    public static BaseActivityTaskExportInfo newExportEntity(String activityType, String activityId) {
        Class<? extends BaseActivityTaskExportInfo> exportClass = getExportClass(activityType, activityId);
        try {
            return exportClass.newInstance();
        } catch (Exception e) {
            log.info("获取导出实体失败：", e);
        }
        return new BaseActivityTaskExportInfo();
    }
}
